package thread.summary;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

//回顾Java多线程
public class Detail {
    public static void main(String[] args) {
        new Thread1().start();

        new Thread(new Thread2()).start();

        FutureTask<Integer> futureTask = new FutureTask(new Thread3());
        new Thread(futureTask).start();

        try {
            Integer integer = futureTask.get();
            System.out.println(integer);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}

//1.继承Thread类
class Thread1 extends Thread {
    @Override
    public void run() {
        System.out.println("Thread1");
    }
}

//2.继承Runnable接口
class Thread2 implements Runnable {
    @Override
    public void run() {
        System.out.println("Thread2");
    }
}

//3.继承Callable接口
class Thread3 implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("Thread3");
        return 999;
    }
}